{script src="scripts/imagebox/jquery-ui-personalized-1.6rc1.packed.js"}
{script src="scripts/imagebox/jquery-imagebox.js"}

{style src="styles/imagebox.css"}

{php}
    $this->assign(array(
        'photo_thumbs_sorage' => Kernel_Config::get('gallery', 'photo_thumbs_sorage'), 
        'photo_sorage' => Kernel_Config::get('gallery', 'photo_sorage'), 
    ));
    
    
    // split entries into groups
    $tmp_entries = $this->get_template_vars('entries');
    $cells = 4;
    $total = ceil(count($tmp_entries) / $cells);
    $entries = array();
    $i = 0;
    while($i < ($total)) {
        $entries[] = array_splice($tmp_entries, 0, $cells);
        $i ++;
    }
    $this->assign('entries', $entries);

{/php}

<script type="text/javascript">
    var ENV = 'frontend';
    var ImageBoxes = {$image_box};
    var tags = {$tags_image_box};
</script>

<table id="gallery" width="100%" border="0" cellspacing="1" cellpadding="0"{if $total} style="background-color:#08314f;"{/if}>
{if $total}
    
    {assign var="cells_number" value=4}
    {foreach from=$entries item="row"}
        
        <tr class="image_bg">
            {section name="cells" loop=$cells_number}
                <td class="image">
                    {if isset($row[$smarty.section.cells.index])}
                        {assign var="entry" value=$row[$smarty.section.cells.index]}
                        
			{html_image file=$photo_thumbs_sorage|cat:$entry.file class="ImageBoxClick" id=$entry.id}
			
                    {/if}
                </td>
            {/section}
        </tr>
        <tr class="caption_bg">
            {section name="cells" loop=$cells_number}
		    {if isset($row[$smarty.section.cells.index])}
                        {assign var="entry" value=$row[$smarty.section.cells.index]}
		    {/if}
                <td class="caption" align="left" valign="{if isset($tags[$entry.id])}top{else}middle{/if}">
                    {if isset($row[$smarty.section.cells.index])}
                        {assign var="entry" value=$row[$smarty.section.cells.index]}

			{if isset($tags[$entry.id])}
			    <div class="tags">
				<strong>Теги:</strong>
				{foreach from=$tags[$entry.id] item="tag" name="tags"}
					<a href="tag/{$tag.id}.html">{$tag.name|escape}</a>{if not $smarty.foreach.tags.last}, {/if}
				{/foreach}

				<div class="hr"></div>
			    </div>
			{/if}

			<div class="image_caption">{$entry.title|escape}</div>

			
                    {/if}
                </td>
            {/section}
        </tr>
        
    {/foreach}
    
{else}
    
    <tr class="content_bg_images">
        <td align="center" valign="middle" id="photo_empty">
            {"CATEGORY_HAS_NO_PHOTOS"|translate}
        </td>
    </tr>
    
{/if}
</table>